home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / dbase / makeactive.c < prev    next >
C/C++ Source or Header  |  1996-07-23  |  2KB  |  70 lines

  1.  
  2. #include "dbase.p"
  3.  
  4. /*
  5.     Make a new active file for destination 'dest'
  6. */
  7. void make_activefile(unsigned uid, int dest)
  8. {
  9.     FILE
  10.         *inf,
  11.         *outf,
  12.         *logfile;
  13.     time_t
  14.         ltime;
  15.     char
  16.         name[10],      /* Username, reduced to 8 chars */
  17.         *fname;
  18.     int
  19.         ret;
  20.     /*
  21.     the source is either the name from the phonelist index, or when
  22.     not given: the default callback definitions file
  23.     */
  24.     if (!(fname = get_filename(dest)))   /* sourcefile may be specified   */
  25.         fname = filename[the_callbackfile];
  26.  
  27.     log(log_max, "make_activefile() to read %s", fname);
  28.     
  29.     inf = xfopen(fname, "r");            /* open the callback-file        */
  30.  
  31.     log(log_max, "make_activefile() to write %s", filename[the_activefile]);
  32.     
  33.                         /* and the temporary file   */
  34.     outf = xfopen(filename[the_activefile], "w");
  35.         
  36.     ret = to_activefile(dest, outf, inf);   /* copy info to active file */
  37.     
  38.     fclose (inf);
  39.     fclose (outf);
  40.  
  41.     if (ret)                                /* error in copying, reset to */
  42.     {                                       /* enable-state               */
  43.         enable_state();
  44.         error("Copy failure, resetting");
  45.     }
  46.  
  47.     log(log_on, "make_active() copy to %s completed", filename[the_activefile]);
  48.  
  49.     if ((logfile = fopen (get_diallogfilename(), "a")))
  50.     {
  51.         time (<ime);
  52.         strncpy(name, username(uid), 8);   /* reduce username to 8 */
  53.         name[8] = 0;
  54.         fprintf
  55.         (
  56.             logfile,
  57.                 "%s"
  58.                 "calling %s at %s (%s V %s)\n"
  59.             , ctime (<ime)
  60.             , name
  61.             , get_dname(dest)
  62.             , getprogname()
  63.             , version
  64.         );
  65.      fclose(logfile);
  66.     }
  67.  
  68.     log(log_max, "make_active(): call logged on %s", get_diallogfilename());
  69. }
  70.